<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/06/02
// +----------------------------------------------------------------------

namespace app\erp\validate;

use think\Validate;

/**
 * 公共类 验证器 采购单验证
 * @package app\admin\validate
 * @author shiqiang
 */
class Purchase extends Validate
{
    protected $rule = [
		'id'					=> 'require|number|gt:0',
		// 'user_id'				=> 'require|number|gt:0',
		'title'					=> 'require',
		'supplier_id'			=> 'require|number|gt:0',    // 供应商id
		'procurement_method'	=> 'require|number|in:1,2', // 采购方式 1现购 2赊购
		'arrival_warehouse_id'	=> 'require|number|gt:0',    // 到货仓id
		// 'advance_charge'		=> 'require',   			 // 预付款
		'arrival_days'			=> 'require|number|gt:0',    // 到货天数
		'remark'				=> 'require',    			 // 备注
		'handled_by'			=> 'require',    			 // 经办人
		// 'purchase_sku'			=> 'require|array',    		 // 采购sku
    ];

    protected $message  =   [
        'id' 					=> 'id格式错误',
        'user_id' 				=> 'user_id格式错误',
        'supplier_id' 			=> 'supplier_id格式错误',
        'procurement_method'	=> 'procurement_method格式错误',
        'arrival_warehouse_id'	=> 'arrival_warehouse_id格式错误',
        'advance_charge' 		=> 'advance_charge格式错误',
        'arrival_days' 			=> 'arrival_days格式错误',
        'remark' 				=> 'remark格式错误',
        'handled_by' 			=> 'handled_by格式错误',
        'purchase_sku' 			=> 'purchase_sku格式错误',
    ];

    //验证场景
    protected $scene = [
		'purchase_list'=>  [//列表
			'user_id',
        ],
        'purchase_add'=>  [//添加
			'user_id',
			'supplier_id',
			'procurement_method',
			'arrival_warehouse_id',
			'advance_charge',
			'arrival_days',
			'handled_by',
			'purchase_sku',
        ],
		'purchase_details'=>  [//详情
			'user_id',
			'id',
        ],
    ];
}
